module VideosHelper

  def self.format_bytes(s)
    s = s.to_f / 1024.0
    units = ' KB'

    if s > 1024
      s /= 1024.0
      units = ' MB'
    end

    s = '%.2f' % s

    {} while s.gsub!(/^(\d+)(\d{3})/, '\1,\2')

    s + units
  end

end
